import { createStore, applyMiddleware } from "redux";
import { defReducer } from "./reducers";

// 导入saga
import { defSaga } from "./sagas";
import createSagaMiddleware from 'redux-saga'

// 调用一下这个函数,来构建sagaMiddleware
const sagaMiddleware = createSagaMiddleware()

// 构建store,通过applyMiddleware关联saga和middleware
export default createStore(defReducer, {}, applyMiddleware(sagaMiddleware))

// 利用middleware 来run一下
sagaMiddleware.run(defSaga)